﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MbUnit.Framework;
using NBehave.Spec.MbUnit;
using NBehave.Specs;
using NBehave;

using UseFixture = Cid.Data.FixtureAttribute;
using Describes = MbUnit.Framework.TestsOnAttribute;
using Should = MbUnit.Framework.DescriptionAttribute;
using AndConcerns = MbUnit.Framework.CategoryAttribute;
using It = MbUnit.Framework.TestAttribute;
using InContext = MbUnit.Framework.DescriptionAttribute;
using By = MbUnit.Framework.AuthorAttribute;


namespace Cid.Models
{
	[
		TestFixture,
		Describes(typeof(ConferenceEvent)),
		AndConcerns("Functional Tests"),
		InContext("Should interact with the database"),
		By("MichaelHerndon", "mherndon@opensourceconnections.com"),
		UseFixture("ConferenceEvents")
	]
	public class ConferenceEventObject: Spec 
	{

		[It, Should(" have a count of 2 events when testing.")]
		public void GetEventCount()
		{
			using (CidDataContext db = new CidDataContext(Spec.ConnectionString))
			{
				var x = ConferenceEvent.Find(db);
				Assert.AreEqual(x.Count(), 2);
			}
		}

		[It, Should (" get an event by name ")]
		public void GetEventByName()
		{
			var x = ConferenceEvent.Find(o => o.Name == "Social Networking 2.0");
			x.Count();
			ConferenceEvent cEvent = x.FirstOrDefault();
			cEvent.ShouldNotBeNull();
			cEvent.Name.ShouldBe("Social Networking 2.0");
		}
	}
}
